
/*
 * @Author: zhangyukele
 * @Date: 2019-09-25 10:10:36
 * @LastEditors: zhangyukele
 * @LastEditTime: 2019-09-25 11:40:35
 * @Description: button组件
 */
import React, { Component } from 'react'
import { Text, View, TouchableOpacity,StyleSheet,Image } from 'react-native'
import BD_noRepeat from '../BD_noRepeat'
import PropTypes from 'prop-types'


export default class BD_button extends Component {
  static propTypes = {
    text: PropTypes.string,
    pressHandler: PropTypes.func, //点击操作函数
    wrapStyle: PropTypes.oneOfType([ //包裹层的样式
      PropTypes.array,
      PropTypes.object,
    ]), 
  }

  static defaultProps = {
    text: '我是button',
    pressHandler: ()=>{},
    wrapStyle: {},
  }


  constructor (props) {
    super(props);
    this.state = {

    }
    this.repeatFlag = true //是否可点击标识符 true 可点击
    this.lessTime = props.timeInterval //剩余倒计时
    this.timer = null; //倒计时定时器
  }

  setStyle(){
    const {wrapStyle} = this.props;
    let wraps;
    //是数组的情况
    if(Array.isArray(wrapStyle)){
      wraps= wrapStyle
    }else{
      wraps= [wrapStyle]
    }

    return wraps
  }


  render() {
    const {children,text} = this.props;
    return (
      <BD_noRepeat wrapStyle={[styles.limitStyle,...this.setStyle()]}>
        <Image source={require('../img/timg.jpg')} style={{width: 20, height: 20}}></Image>
        <Text style={[styles.textStyle]}>{text}</Text>
      </BD_noRepeat>
    )
  }
}

const styles = StyleSheet.create({
  limitStyle: {
    minWidth: 40,
    minHeight: 40,
    justifyContent: 'center',
    alignItems: 'center'
  },
  textStyle: {
    lineHeight: 40,
  },
  wraps: {
    // backgroundColor: 'blue'
  }
})
